<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<style type="text/css">
			*{
				margin: 0;
				padding: 0;
			}
			
			ul{
				list-style: none;
			}
			
			li:nth-of-type(2n){
				background-color: red;
			}
			
			li:nth-of-type(2n +1){
				background-color: green;
			}
		</style>
	</head>
	<body>
		
		<!--<ul>
			<li>a</li>
			<li>a</li>
			<li>a</li>
			<li>a</li>
		</ul>-->
		
		<script type="text/javascript">
			
			
			/*var liCollection = document.getElementsByTagName('li');
			for (var i = 0; i < liCollection.length; i++) {
				liCollection[i].onclick = function(){
					console.log(i);
				}//错误
			}*/
			
			/*var liCollection = document.getElementsByTagName('li');
			for (var i = 0; i < liCollection.length; i++) {
				(function(j){
					liCollection[j].onclick = function(){
						console.log(j);
					}
				}(i));//正确
			}*/
			
			/*function test(){
				var count = 0;
				function sum(){
					count++;
					console.log(count);
				}
				return sum;
			}
			
			var demo = test();
			demo();*/
			
			/*function add(){
				var num = 0;
				function a(){
					console.log(++num);
				}
				return a;
			}
			
			var myAdd = add();
			myAdd();
			myAdd();
			myAdd();*/
			
			/*function test(){
				var food = 'apple';
				var obj = {
					eatFood : function (){
						if(food != ""){
							console.log(food);
							food = "";
						}else{
							console.log("There is nothing");
						}
						
					},
					pushFood :function(myFood){
						food = myFood;
					}
				}
				return obj;
			}
			
			var person = test();
			person.eatFood();
			person.eatFood();
			person.pushFood('banana');
			person.eatFood();*/
			
			/*function test(){
				var arr = [];
				for (var i = 0; i < 10; i++) {
					(function(j){
						arr[j] = function(){
							console.log(j);
						}
					}(i));
				}
				return arr;
			}
			
			var arrDemo = test();
			for (var i = 0; i < 10; i++) {
				arrDemo[i]();
			}*/
			
			/*a = 100;
			function demo(e){
				function e(){}
				arguments[0] = 2;
				document.write(e);//2
				if(a){
					var b = 123;
					function c(){}
				}
				var c;
				a = 10;
				var a;
				document.write(b);//un
				f = 123;
				document.write(c);//un
				document.write(a);//10
			}
			var a;
			demo(1);
			document.write(a);//100
			document.write(f);//123*/
			
			/*//计算字节长度
			var str = "ewe,我dsam多的的发都发";
			var len = str.length;
//			for (var i = 0; i < str.length; i++) {
//				len += str.charCodeAt(i) > 255;
//			}
			console.log(str.charCodeAt(100));//NaN
			for (var i = 0; i < len; i++) {
				if(str.charCodeAt(i) > 255){
					len ++;
				}
			}
			
			console.log(str.charCodeAt(100));//NaN
			for (var i = 0; i < len; i++) {
				len += str.charCodeAt(i) > 255;//利用Number(false) = 0;Number(true) = 1 
			}
			console.log(len);*/
			
			
			/*var f = (
				function f(){
					return "1";//string
				},
				function g(){
					return 2;
				}
			)();
			console.log(typeof f);//number*/
			
			/*var x = 1;
			if(function f(){}){
				x += typeof f;
			}
			
			console.log(x);//1undefined*/
			
			
			
			
						
				
		</script>
	</body>
</html>
